package com.gasolinator.a.listener;

import android.content.Context;
import android.location.Location;
import android.location.LocationListener;
import android.os.Bundle;
import android.widget.Toast;
import com.gasolinator.a.augmented_reality.data.ARData;
import com.gasolinator.a.augmented_reality.data.GasolinatorDataSource;

/**
 * Created by IntelliJ IDEA.
 * User: fjhidalgo
 * Date: 18/12/11
 * Time: 12:30
 * To change this template use File | Settings | File Templates.
 */
public class MyLocationListener implements LocationListener

{

    private Context context;
    private GasolinatorDataSource gasolinatorDataSource;

    public MyLocationListener(Context context, GasolinatorDataSource gasolinatorDataSource) {
        this.context = context;
        this.gasolinatorDataSource = gasolinatorDataSource;
    }

    @Override

    public void onLocationChanged(Location loc)

    {
        double lat = loc.getLatitude();
        double lon = loc.getLongitude();
        Toast.makeText( context,lat+", "+lon,Toast.LENGTH_SHORT).show();
        gasolinatorDataSource.refresh(context, ARData.getCurrentLocation(),ARData.getRadius());

    }

    @Override
    public void onProviderDisabled(String provider)
    {
        Toast.makeText( context,"gps enabled",Toast.LENGTH_SHORT ).show();
    }

    @Override
    public void onProviderEnabled(String provider)
    {
        Toast.makeText( context,"gps enabled", Toast.LENGTH_SHORT ).show();
    }

    @Override
    public void onStatusChanged(String provider, int status, Bundle extras)
    {

    }

}